import axios from 'axios'

const service = axios.create({
  baseURL: '' // mockjs模拟数据这里必须为空,否则请求报404 
})

// 请求拦截器
service.interceptors.request.use(config => {
  return config;
})

// 响应拦截器
service.interceptors.response.use(res => {
  return res;
}, err => {
  return Promise.reject(err)
})

// echart图表数据
export const getLineData = () => {
  return service.get('/getLineData')
}
export const getPieData = () => {
  return service.get('/getPieData')
}
export const getBarData = () => {
  return service.get('/getBarData')
}
export const getTableData = () => {
  return service.get('/getTableData')
}

// 用户接口
export const getUserList = (data) => {
  return service.post('/getUserList', data)
}
export const getUserById = (id) => {
  return service.get(`/getUserById?id=${id}`)
}
export const addUser = (data) => {
  return service.post('/addUser', data)
}
export const deleteUser = (data) => {
  return service.post('/deleteUser', data)
}
export const updateUser = (data) => {
  return service.post('/updateUser', data)
}